﻿
--离职审批
CREATE proc [dbo].[proc_Employee_Dimission_Audit]
(
	@Id int,
	@Audit bit,
	@Memo text,
	@UserName nvarchar (50),
	@lzrq nvarchar (50),
	@AuditTime nvarchar(50)

)
as
		begin
			update Employee_Dimission set Audit=@Audit,Memo=@Memo,AuditPerson=@UserName,AuditTime=@AuditTime where id=@id
			--审批通过，员工状态变为5(离职)
			declare @eid int,@TUserName varchar(50)
			select @eid=eid from Employee_Dimission where id=@id
			if(@audit=1)
				begin
					update employee set State=5,LizhiDate=@lzrq where id=@eid
				end
			else
				begin
				--	如果审批未通过，将登录表中的账号恢复为正常可登录状态，角色需要重新手动设置 2015.4.3 GSJ
				Select @TUserName=UserName From Employee Where Id=@eid
					Update aspnet_Users Set IsLockout=0 Where UserName=@TUserName
				end
			Select @eid as 'RETUNR_V'
		end
RETURN